package day08.synch02._03;

/**
 * <>
 * <详细描述>
 *
 * @Author WANG.SONG.
 * @Date 2019/3/5 0005 23:24
 * @see
 */
public class Service {

    private String userNameParam;

    private String passwordParam;

    public void setUserNamePassword(String userName,String password){
        String anyString = new String();
        Integer i =0;
        synchronized (anyString){
            System.out.println("线程名："+Thread.currentThread().getName()+
                    "在"+System.currentTimeMillis() +"进入同步代码块");
            userNameParam = userName;
            try {
                Thread.sleep(3000);
                passwordParam = password;
                System.out.println("线程名："+Thread.currentThread().getName()+
                        "在"+System.currentTimeMillis() +"离开同步代码块");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
